<?php

define('PAYMENT_DIR',realpath(dirname(__FILE__).'/../'));
/**
 * Payment 
 * 
 * @package 
 * @version $1.0.0$
 * @copyright 1997-2005 The PHP Group
 * @author xiudong.yang <xiudong12@gmail.com> 
 * @license PHP Version 3.0 {@link http://www.php.net/license/3_0.txt}
 */
class Payment
{ 
    /**
     * set 设置适配器的名字和初始化的参数 
     * 
     * @param string $adapterName
     *  支付宝:Alipay
     *  财付通:Tempay
     *  网银中国:Chinapay
     *  快钱:Bill99
     * 
     * @param array $configs 
     * @static
     * @access public
     * @return object 
     */
    public static function set($adapterName,$configs) 
    {
        if(!$adapterName) 
            throw new Payment_Exception('没有适配器的名字');

        $adapterName = 'Payment_Adapter_'.ucwords($adapterName);
        $classFile = dirname(__FILE__).DIRECTORY_SEPARATOR.'Adapter'.DIRECTORY_SEPARATOR.ucwords($name).'.php';

        if(!is_file($classFile))
            throw new Payment_Exception('适配器类'.$className.':'.$classFile.'不存杂');

        require_once $classFile;

        return new $adapterName($configs);
    }
}
?>
